package aop;

import org.aopalliance.intercept.Joinpoint;
import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.junit.Before;
import org.slf4j.LoggerFactory;


import java.util.Arrays;

public class LoggerAspect {
    private static final Logger log = (Logger) LoggerFactory.getLogger(LoggerAspect.class);
    public void before(JoinPoint jp){
        log.info("【LoggerAspect 前置增强】正在调用{}的{}方法。方法入参：{}");
        log.info(jp.getTarget());
        log.info(jp.getSignature().getName());
        log.info(Arrays.toString(jp.getArgs()));
    }

    public void afterReturning(JoinPoint jp,Object result){
        log.info("【LoggerAspect 后置增强】调用{}的{}方法。方法返回值：{}");
        log.info(jp.getTarget());
        log.info(jp.getSignature().getName());
        log.info(Arrays.toString(jp.getArgs()));
    }
}
